
''' 火焰图像特征量 '''

import numpy as np
# 求输入图像在掩膜覆盖下像素点的修正均值
# 求火焰区域的平均灰度,面积（火焰区域像素点个数）



def MeaArea(image, mask):
    sum = 0.0
    area = 0
    # 图像矩阵的行数和列数
    rows, cols = image.shape
    for r in range(rows):
        for c in range(cols):
            if (mask[r,c] != 0):
                sum += image[r, c]
                area = area + 1
    if area:
        return np.mean(image), sum / area, area
    else:
        return np.mean(image), sum, area

# 求输入图像的掩膜覆盖下像素点的面积,即像素个数
# 求火焰区域的面积（火焰区域像素点个数）
def Area(image, mask):
    area = 0
    # 图像矩阵的行数和列数
    rows, cols = image.shape
    for r in range(rows):
        for c in range(cols):
            if (mask[r,c] != 0):
                area = area + 1
    return area


